
function  microcircleListtableRefre(){
    microcircleListtableI.reload('microcircleListtableId');
}
var microcircleListtableI = null;
layui.use(['table', 'laydate','form'], function(){
        var table = layui.table,
        laydate = layui.laydate,
        form = layui.form;

        laydate.render({
                elem: '#rq', //指定元素
        });


    microcircleListtableI = table.render({
                elem: '#test',
                url:'/microcycleManagement/getAll2'+'?userId='+localStorage.getItem("uid"),
                id:'microcircleListtableId',
                page:{
                    layout:['count','prev','page','next','limit'],
                    groups:2,
                    limit:10,
                    limits:[10,15,20]

                },
                cols: [[
                        {field:'id', width: 120, title: '微圈编号',align:'center'},
                        {field:'userAccount', width: 180, title: '用户账号',align:'center'},
                        {field:'microcircleTime', width: 250, title: '发表时间',align:'center'},
                    {field:'fabulousNum', width: 120, title: '点赞人数',align:'center'},
                    {field:'commentNum', width: 120, title: '评论人数',align:'center'},
                         {field:'reviewStatus', width:120,align:'center', title: '状态',templet: function(row){
                            if(row.reviewStatus == '0'){
                                return '已审核';
                            }else if(row.reviewStatus == '1'){
                                return '未审核';
                            }else if(row.reviewStatus == '2'){
                                return '已驳回';
                            }
                        }},
                        {fixed: '', title:'操作', minWidth: 80,toolbar: '#barDemo',align:'center'}
                ]],
                toolbar:'#toolbarDemo',
                skin: 'line',
                parseData:function (res){
                        return{
                                "code":res.code, // 解析接口状态
                                "msg": res.msg, // 解析提示文本
                                "count": res.count, // 解析总条数
                                "data": res.data // 解析数据列表
                        };
                }
        });

        table.on('tool(test)', function(obj){ // 双击 toolDouble
            if(obj.event === 'ck') {
                layer.open({
                    type: 2,
                    title: '查看详情信息',
                    content: "microcircleListSee.html",
                    area: ['80%', '80%'],
                    success: function () {
                        var boby = layer.getChildFrame('body,index');
                        boby.find("td[name = id]").text(obj.data.id);
                        boby.find("td[name = userAccount]").text(obj.data.userAccount);
                        boby.find("td[name = microcircleTime]").text(obj.data.microcircleTime);
                        if (obj.data.reviewStatus == 0) {
                            boby.find("td[name = reviewStatus]").text('已审核');
                        } else if(obj.data.reviewStatus == 1){
                            boby.find("td[name = reviewStatus]").text('未审核');
                        } else if(obj.data.reviewStatus == 2){
                            boby.find("td[name = reviewStatus]").text('已驳回');
                        }
                        boby.find("td[name = microcircleTime]").text(obj.data.microcircleTime);
                        boby.find("td[name = fabulousNum]").text(obj.data.fabulousNum);
                        boby.find("td[name = commentNum]").text(obj.data.commentNum);
                        boby.find("td[name = publishedText]").text(obj.data.publishedText);
                        boby.find("td[name = publishPicture]").html('<div><img src="' + obj.data.publishPicture + '", ' +
                            'style="width: 200px;height: 100px"></div>');
                        boby.find("td[name = publishVideo]").html('<div><video src="' + obj.data.publishVideo + '"style="width: 800px;height: 600px" controls></video> </div>');


                    }
                })
            }else if(obj.event === 'sh'){
                // layer.msg("审核");
                layer.confirm("你是否通过(驳回)编号为"+obj.data.id+"的请求", {
                    btn: ['通过','驳回'],
                    btn1: function(){
                        $.ajax({
                            type: 'post',
                            url: '/microcycleManagement/upReviewStatus',
                            data: {id: obj.data.id, reviewStatus: 0},
                            dataType: 'json',
                            success: function (res) {
                                if (res.state == '200') {
                                    layer.msg('已经通过审核',{icon:6,time:1000},function (){
                                        layer.close(index);
                                        microcircleListtableRefre();
                                    })
                                } else {
                                    layer.msg('通过审核失败', {icon: 5, time: 1000}, function () {
                                        layer.close(index);
                                    })
                                }
                            }
                        })

                    },
                    btn2: function(){
                        $.ajax({
                            type: 'post',
                            url: '/microcycleManagement/upReviewStatus',
                            data: {id: obj.data.id, reviewStatus: 2},
                            dataType: 'json',
                            success: function (res) {
                                if (res.state == '200') {
                                    layer.msg('已经驳回审核',{icon:6,time:1000},function (){
                                        layer.close(index);
                                        microcircleListtableRefre();
                                    })
                                } else {
                                    layer.msg('驳回审核失败', {icon: 5, time: 1000}, function () {
                                        layer.close(index);
                                    })
                                }
                            }
                        })

                    }
                })
            }else if(obj.event === 'sh2') {
                layer.confirm("你是否通过编号为" + obj.data.id + "的请求", function () {
                    $.ajax({
                        type: 'post',
                        url: '/microcycleManagement/upReviewStatus',
                        data: {id: obj.data.id, reviewStatus: 0},
                        dataType: 'json',
                        success: function (res) {
                            if (res.state == '200') {
                                layer.msg('已经通过审核',{icon:6,time:1000},function (){
                                    layer.close(index);
                                    microcircleListtableRefre();
                                })
                            } else {
                                layer.msg('通过审核失败', {icon: 5, time: 1000}, function () {
                                    layer.close(index);
                                })
                            }
                        }
                    })
                })
            }

        });

        form.on('submit(go)',function (d){
                d = d.field;
                console.log(d);
                table.reload('microcircleListtableId',{
                        where:{
                            userAccount:d.userAccount,
                            microcircleTime:d.microcircleTime,
                            reviewStatus:d.reviewStatus
                        }
                });
        })


});
